package com.shuji.android.library;

import android.content.Context;

import com.shuji.android.library.rx.RxManager;

/**
 * BasePresenter：引用Model和View,同时持有context,还使用了RxManager
 *
 *
 * @param <T>
 * @param <E>
 */
public abstract class BasePresenter<T, E> {
    private Context mContext;

    private E mModel;
    private T mView;


    private RxManager mRxManage = new RxManager();


    /**
     * 注入视图、模型和Context，并触发start事件
     *
     * @param context
     * @param view
     * @param model
     */
    public void inject(Context context, T view, E model) {
        mContext = context;
        mView = view;
        mModel = model;
        onStart();
    }

    public void inject(T view, E model) {
        mView = view;
        mModel = model;
        onStart();
    }



    public Context getContext() {
        return mContext;
    }

    public E getModel() {
        return mModel;
    }

    public T getView() {
        return mView;
    }

    public RxManager getRxManage() {
        return mRxManage;
    }


    //-----------------------------------------------------------------------------
    /**
     * 出发start事件
     *
     */
    public void onStart() {
    }

    /**
     * 出发
     *
     */
    public void onDestroy() {
        mRxManage.clear();
    }
}
